<%-- 
    Document   : login_validation
    Created on : 22 May, 2012, 3:33:16 PM
    Author     : bharat
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<!--<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        
    </body>
</html> -->
<%@page import="java.sql.*" %>

<%
    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    Class.forName("oracle.jdbc.driver.OracleDriver");
    con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "aksh", "aksh");

    String usr = request.getParameter("usr");
    String pwd = request.getParameter("pwd");
    try {
        pstmt = con.prepareStatement("select *from registered_users_db where usr_name=? and usr_pwd=?");
        pstmt.setString(1, usr);
        pstmt.setString(2, pwd);
        rs = pstmt.executeQuery();
        if (rs.next()) {
            session.setAttribute("usr", usr);
            response.sendRedirect(".acc");
        } else {
            response.sendRedirect(".ind");
        }
    } catch (Exception e) {
        response.sendError(555, e.getMessage());
        e.printStackTrace();
    } finally {
        if (rs != null) {
            try {
                rs.close();
            } catch (Exception e) {
                response.sendError(555, e.getMessage());
            }
        }
        if (pstmt != null) {
            try {
                pstmt.close();
            } catch (Exception e) {
                response.sendError(555, e.getMessage());
            }
        }
        if (con != null) {
            try {
                con.close();
            } catch (Exception e) {
                response.sendError(555, e.getMessage());
            }
        }
    }
%>
